package matrix.world.volleyball;

import android.graphics.Canvas;
import android.view.SurfaceHolder;

public class MyThread extends Thread {
	static final long FPS = 60;
	private MySurfaceView mySufaceView;
    private SurfaceHolder mHolder;
    private boolean running = false;
    
    public MyThread(MySurfaceView mySufaceView) {
        this.mySufaceView = mySufaceView;
        mHolder = mySufaceView.getHolder();
    }
    
    public void setRunning(boolean run) {
        running = run;
    }

    @Override
    public void run() {
        while (running) {
        	Canvas c = null;
        	mySufaceView.doAnimate();
    		try {
    			c = mHolder.lockCanvas();
    			synchronized (mHolder) {
    				if (c!=null) mySufaceView.doDraw(c);
    			}
    		} finally {
    			if (c != null) {
    				mHolder.unlockCanvasAndPost(c);
    			}
    		}
        }
    }
}